{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>健身房管理系统</title>
    <link rel="stylesheet" href="{% static 'css/input_text.css'%}">
    <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon">
</head>

<style>
    .form-container {
        display: flex; /* 使用flex布局 */
        margin: 0;
        display: flex;
        justify-content: center;
        align-items: center;
    }

</style>

<style>
    .background{
        flex:1;
    background-image: url('/static/background.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
    overflow-y: hidden;
    overflow-x: hidden;
    flex-direction: column;
}
</style>

<style>
    .gradient-text {
        font-size: 50px; /* 设置字体大小 */
        background: linear-gradient(to right, #52E5E7, #130cb7); /* 定义从左到右的红蓝渐变 */
        -webkit-background-clip: text; /* 将背景应用到文本 */
        background-clip: text;
        color: transparent; /*设置文本颜色为透明，以显示背景渐变 */
        font-weight: bold;
        /* display: inline-block; */
    }
  </style>

<style>
    table {
        /* margin-left: auto;
        margin-right: auto; */
        width: 75%;
        border-collapse: collapse;
        margin: 0 auto;
        font-size: 0.9em;
        font-family: sans-serif;
        min-width: 400px;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
    }
    thead tr {
        background-color: #009879;
        color: #ffffff;
        text-align: left;
    }
    th,td {
        
        padding: 12px 15px;
    }
    tbody tr {
        border-bottom: 1px solid #0cc3c6;
    }
    tbody tr:nth-of-type(even) {
        background-color: #9be0f5;
    }
    tbody tr:nth-of-type(odd){
        background-color: #45c7ef;
    }
    tbody tr:last-of-type {
        border-bottom: 2px solid #009879;
    }
    tbody tr.active-row {
        font-weight: bold;
        color: #009879;
    }
</style>

<style>
    /* 选课按钮的样式 */
    .submit-enroll {
        background-color: #4CAF50 !important; /* 按钮背景颜色 */
        color: white; /* 文字颜色 */
        padding: 12px 20px; /* 内边距 */
        margin: 6px 0; /* 外边距 */
        border: none; /* 边框 */
        border-radius: 4px; /* 圆角 */
        cursor: pointer; /* 鼠标悬停时的指针样式 */
        font-size: 16px; /* 字体大小 */
        transition: 0.3s; /* 平滑过渡效果 */
    }
</style>
<style>
    /* 取消按钮的样式 */
    .submit-cancel {
        background-color: red !important; /* 按钮背景颜色 */
        color: white; /* 文字颜色 */
        padding: 12px 20px; /* 内边距 */
        margin: 6px 0; /* 外边距 */
        border: none; /* 边框 */
        border-radius: 4px; /* 圆角 */
        cursor: pointer; /* 鼠标悬停时的指针样式 */
        font-size: 16px; /* 字体大小 */
        transition: 0.3s; /* 平滑过渡效果 */
    }
</style>

<style>
    .sidebar {
        float: left; /* 使侧边栏浮动 */
        left: 0; /* 侧边栏左对齐 */
        height: 100vh;
        width: 250px; /* 设置宽度 */
        margin-right: 20px; /* 与主内容的距离 */
        background-color:rgba(255, 255, 255, 0.5); /* 背景颜色 */
        border: 1px solid #ccc; /* 边框 */
        text-align: center; /* 水平居中 */
        transition: left 0.3s ease;
        overflow: hidden;
    }
    .sidebar a {
        color: black; /* 链接颜色 */
        font-weight: bold; /* 字体加粗 */
        text-decoration: none; /* 去除下划线 */
        font-size: 18px; /* 字体大小 */
        margin: 10px 0;
        display: block;
        text-shadow: 
            1px 1px 1px rgba(255, 255, 255, 0.5), 
            1px 1px 3px rgba(0, 0, 0, 0.5);
        
    }
    .sidebar a:hover {
        text-shadow: 
            1px 1px 1px rgba(255, 255, 255, 0.8), 
            1px 1px 5px rgba(0, 0, 0, 0.8);
        text-decoration: underline; /* 鼠标悬停时添加下划线 */
    }
    .main-content {
        float: left; /* 主内容浮动 */
        width: 230px; /* 计算宽度，假设侧边栏宽200px */
        background-color: rgba(255, 255, 255, 0.5); /* 背景颜色 */
        padding: 10px; /* 填充 */
        border: 1px solid #ccc; /* 边框 */
    }
    .main-content h3{
        text-align: center;
    }
    .clearfix {
        clear: both; /* 清除浮动 */
    }
    .toggle-btn {
        width: 40px;
        height: 30px;
        padding: 10px 15px;
        cursor: pointer;
        position: fixed;
        top: 10px;
        left: 10px;
        z-index: 1000;
        background: linear-gradient(45deg, #ff7e5f, #feb47b);
        border: none; /* Remove border */
        border-radius: 50%; /* Rounded corners */
        box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
        font-size: 16px; /* Button text size */
        outline: none; /* Remove outline */
        transition: background 0.3s ease; /* Transition for hover effect */
    }
    .toggle-btn:hover{
        background: linear-gradient(135deg, #ff7e5f, #feb47b);
        transform: scale(1.2);
    }
    .collapsed {
        width: 0px;
        left: -200px;
    }
</style>

<body>  
    <div class="background">
        <div class="sidebar collapsed" id = "sidebar" onclick="this.classList.toggle('collapsed');">
            <button class="toggle-btn" style="position: absolute; top: 10px; left: 10px;">
                <span></span>
                <span></span>
                <span></span>
            </button>
            <aside>
                <h1>{{ account }}</h1>
                <div class="main-content clearfix">
                    <h3>生命在于运动,健康在于锻炼</h3>
                </div>
                <br><br><br><br><br>
                <a href="..?account={{ account }}&password={{ password }}&option=用户">返回个人主页</a>                          

            </aside>
        </div>
        <div class="audio-control">
            <button id="playPauseBtn" class="audio-btn">
                <svg viewBox="0 0 24 24">
                    <path d="M12 3C7.7 3 3.7 4.4 0 7.7V16.3C3.7 19.6 7.7 21 12 21C16.3 21 20.3 19.6 24 16.3V7.7C20.3 4.4 16.3 3 12 3ZM12 19C8.1 19 4.7 17.5 2 15.1V8.9C4.7 6.5 8.1 5 12 5C15.9 5 19.3 6.5 22 8.9V15.1C19.3 17.5 15.9 19 12 19ZM12 17C13.7 17 15 15.7 15 14C15 12.3 13.7 11 12 11C10.3 11 9 12.3 9 14C9 15.7 10.3 17 12 17Z"></path>
                </svg>
            </button>
        </div>
        <audio id="audio" src="/static/music.mp3" preload="auto"></audio>
        <script>
            document.addEventListener('DOMContentLoaded', function() {
                var playPauseBtn = document.getElementById('playPauseBtn');
                var audio = document.getElementById('audio');
                audio.play();
                playPauseBtn.querySelector('svg').style.fill = '#4CAF50';
                playPauseBtn.addEventListener('click', function() {
                    if (audio.paused) {
                        audio.play();
                        playPauseBtn.querySelector('svg').style.fill = '#4CAF50'; // Change color to indicate playing
                    } else {
                        audio.pause();
                        playPauseBtn.querySelector('svg').style.fill = '#333'; // Reset color
                    }
                });
            });
        </script>
        <h1 class="gradient-text" style = "text-align: center;" >
            我的预约
        </h1>
        <form action="" method="get" class = 'form-container'> 
            <input type="hidden" name="account" value="{{ account }}">
            <input type="hidden" name="password" value="{{ password }}"> 
            <input type="hidden" name="option" value="用户">
        </form>
        <div style="max-height: 60vh; overflow-y: auto; margin: 20px auto; width: 85%;">
            <table>
                <thead>
                    <tr>
                        <th>课程ID</th>
                        <th>课程名</th>
                        <th>时间</th>
                        <th>地点</th>
                        <th>已报名人数</th>
                        <th>教练</th>
                        <th>选课</th>
                    </tr>
                </thead>
                <tbody>
                    {% for item in course_list %}
                    <tr>
                        <td>{{ item.course_id }}</td>
                        <td>{{ item.course_name }}</td>
                        <td>{{ item.time }}</td>
                        <td>{{ item.location }}</td>
                        <td>{{ item.enrolled }}</td>
                        <td>{{ item.coach_name }}</td>
                        <td>
                            {% if item.is_mycourse == 'no' %} 
                            <form action="" method="get"> 
                                <input type="hidden" name="account" value="{{ account }}">
                                <input type="hidden" name="password" value="{{ password }}"> 
                                <input type="hidden" name="option" value="用户">
                                <input type="hidden" name="coach_name" value="{{item.coach_name}}">        
                                <input type="hidden" name="course_id" value="{{item.course_id}}">                       
                                <input type="submit" calss="submit-enroll" name = "选课" value="选课" > 
                            </form>
                            {% else %}
                            <form action="" method="get"> 
                                <input type="hidden" name="account" value="{{ account }}">
                                <input type="hidden" name="password" value="{{ password }}"> 
                                <input type="hidden" name="option" value="用户">    
                                <input type="hidden" name="coach_name" value="{{item.coach_name}}">   
                                <input type="hidden" name="course_id" value="{{item.course_id}}">                             
                                <input type="submit" class="submit-cancel" name = "取消" value="取消" >                            
                            </form>
                            {% endif %}
                    </tr>
                    {% empty %}
                    <tr>
                        <td>NO COURSE EXISTS.</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
    
</body>
</html>